﻿using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace SSC.Models
{
    /// <summary>
    /// 槽位模型类
    /// </summary>
    public class SlotModel : INotifyPropertyChanged
    {
        public int SlotNumber { get; set; } // 槽号（1~30）
        public string SlotName { get; set; } // 槽名称，例如“槽01”、“槽02”

        // 产品相关字段（可以为空）
        public string? PCode { get; set; }      
        public string? PartName { get; set; } //料号

        // PLC相关实时数据（可从PLC读取，也可为空）
        public double? SetCurrent { get; set; }         // 设定电流
        public double? ActualCurrent { get; set; }      // 实际电流
        public double? SetTemperature { get; set; }     // 设定温度
        public double? ActualTemperature { get; set; }  // 实际温度
        public int? SetTime { get; set; }              // 设定时间
        public int? CurrentTime { get; set; }          // 当前时间
        public int? Remark1 { get; set; }              
        public string? Remark2 { get; set; }
        public string? Remark3 { get; set; }
        public string? Remark4 { get; set; }
        public string? Remark5 { get; set; }

        public event PropertyChangedEventHandler? PropertyChanged;
        protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        //带参构造函数
        public SlotModel(int slotNumber, string slotName)
        {
            SlotNumber = slotNumber;
            SlotName = slotName;
        }

        //增加一个方法来清空槽位数据（例如当槽位被重置时）
        public void ResetSlotData()
        {
            PCode = null;
            PartName = null;
            SetCurrent = null;
            ActualCurrent = null;
            SetTemperature = null;
            ActualTemperature = null;
            SetTime = null;
            CurrentTime = null;
            Remark5 = null;
            Remark1 = null;
            Remark2 = null;
            Remark3 = null;
            Remark4 = null;
        }

    }
}
